package com.iot.core.data;

import com.iot.core.util.MyDateTime;
import io.swagger.v3.oas.annotations.media.Schema;

import lombok.Data;
import org.springframework.util.StringUtils;

import java.util.Date;

@Data
@Schema(name = "BasePageQto",description = "")
public class BasePageDtQto extends BasePageQto {


    @Schema(name = "开始日期",description = "")
    private  String  dtb ="";

    @Schema(name = "截至日期",description = "")
    private  String  dte ="";

    public Date getDB()   {
        if(StringUtils.hasText(dtb)){
            try {
                return MyDateTime.parse(dtb );
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
        return  null;
    }
    public Date getDE()   {
        if(StringUtils.hasText(dte)){
            try {
                return MyDateTime.addDay(  MyDateTime.parse(dte.substring(0,10) ),1);
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
        return  null;
    }
}
